<template>
  <div>
    <h5>通用后台管理系统</h5>
    <el-row class="tac">
      <!-- <h5>自定义颜色</h5> -->
      <el-menu default-active="2"
        class="el-menu-vertical-demo" 
        @open="handleOpen" 
        @close="handleClose"
        background-color="#545c64" 
        text-color="#fff" 
        active-text-color="#ffd04b"
        :collapse="collpse">
        <router-link to="/">
          <el-menu-item index="1">
            <i class="el-icon-s-home"></i>
            <span slot="title">首页</span>
          </el-menu-item>
        </router-link>
        <router-link to="/goods">
          <el-menu-item index="2">
            <i class="el-icon-s-order"></i>
            <span slot="title">商品管理</span>
          </el-menu-item>
        </router-link>
        <router-link to="/mine">
          <el-menu-item index="3">
            <i class="el-icon-user-solid"></i>
            <span slot="title">我的</span>
          </el-menu-item>
        </router-link>
        <router-link to="/users/">
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item-group>
              <router-link to="/users/"><el-menu-item index="1-1">page1</el-menu-item></router-link>
              <router-link to="/users/page2"><el-menu-item index="1-2">page2</el-menu-item></router-link>
            </el-menu-item-group>
          </el-submenu>
        </router-link>
      </el-menu>
    </el-row>
  </div>
</template>

<script>
import bus from '@/EvenBus.js'
export default {
  data(){
    return {
      collpse: false
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    getCollpseStatus(){
      bus.$on("collpse", val => {
        this.collpse = val
      })
      console.log(this.collpse);
    }
  }
}
</script>

<style>
  .el-menu{
    height: 100vh
  }
  body{
    margin: 0;
    padding: 0;
  }
</style>